<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自增练习</title>
</head>
<body>
    
</body>
</html>
<script>
    let n1 = 10;
    let n2 = 20;

    var n = n1++;
    console.log("n = "+n);  //10 
    /* n1++ = n1 = 10 = n  n1++等于原变量的值*/
    console.log("n1="+n1);  //11
    /* n1++ = 10+1 = 11*/
    
    n = ++n1;
    console.log("n="+n);    //12
    /* ++n1 =n1+1 = 11+1 = n ++n1等于原变量新值 */
    console.log("n1="+n1);  //12
    /* ++n1 = 11+1 = 12 */


    n = n2--;
    console.log("n="+n);//20
    console.log("n2="+n2);//19
    n  = --n2;
    console.log("n="+n);//18
    console.log("n2="+n2);//18
</script>